def getitem(data_set, min_support):  # 挖掘第一项集
    res = []
    temp = set()
    for i in data_set:
        temp = temp | i

    # 保留支持度满足条件的项
    for i in temp:
        count = 0
        for j in data_set:
            if i in j:
                count += 1

        current_support = count / len(data_set)

        if current_support >= min_support:
            res.append(set(i))

    return res


def _getitem(_item_set, data_set, min_support):  # 渠道项集并且排除支持度小于最小支持度的项
    res = []

    # 保留支持度满足条件的项
    for i in _item_set:
        count = 0
        for j in data_set:
            if i.issubset(j):
                count += 1

        current_support = count / len(data_set)

        if current_support >= min_support:
            res.append(set(i))

    return res


def full_connection(item_set):
    res = []

    if len(item_set) == 1:
        return item_set
    else:
        for i in range(0, len(item_set) - 1):
            j = i + 1
            while j < len(item_set):
                temp_set = item_set[i] | item_set[j]

                if len(temp_set) == len(item_set[i]) + 1 and temp_set not in res:  # 去重
                    res.append(item_set[i] | item_set[j])

                j += 1

        return res
